#!/bin/bash
# This is a simple post deploy hook executed after your application 
# is deployed and started.  This script gets executed directly, so 
# it could be python, php, ruby, etc.

DRUPAL_SITE_DIR=${OPENSHIFT_REPO_DIR}php/sites
for MODULE  in ubercart rules views ctools entity colorbox google_analytics token scheduler libraries wysiwyg panels fusion_accelerator skinr date
do 
  if [ ! -d "${DRUPAL_SITE_DIR}/all/modules/${MODULE}" ]
  then
    echo "Installing module: ${MODULE}"
    drush dl -y ${MODULE}
  else
    echo "Module: ${MODULE} has installed."
  fi
done

if [ ! -d "${DRUPAL_SITE_DIR}/all/libraries" ]
then
  mkdir -pv ${DRUPAL_SITE_DIR}/all/libraries
fi

if [ ! -d "${DRUPAL_SITE_DIR}/all/libraries/colorbox" ]
then
  echo "Installing library: colorbox"
  cd ${DRUPAL_SITE_DIR}/all/libraries/
  wget https://github.com/jackmoore/colorbox/archive/1.x.zip
  unzip 1.x.zip
  mv colorbox-1.x colorbox
  rm 1.x.zip
fi

if [ ! -d "${DRUPAL_SITE_DIR}/all/libraries/tinymce" ]
then
  echo "Installing library: tinymce"
  cd ${DRUPAL_SITE_DIR}/all/libraries/
  wget http://download.moxiecode.com/tinymce/tinymce_3.5.10.zip
  unzip tinymce_3.5.10.zip
  rm tinymce_3.5.10.zip
fi

for THEME  in at-commerce adaptivetheme acquia_marina fusion acquia_prosper
do 
  if [ ! -d "${DRUPAL_SITE_DIR}/all/themes/${THEME}" ]
  then
    echo "Installing theme: ${THEME}"
    drush dl -y ${THEME}
  else
    echo "Theme: ${THEME} has installed."
  fi
done

for MODULE  in uc_cart uc_catalog rules views ctools entity colorbox googleanalytics token scheduler libraries wysiwyg panels date_popup skinr fusion_accelerator fusion_apply fusion_labels fusion_responsive_ie
do
  echo "Enable module: ${MODULE}"
  drush en -y ${MODULE}
done
